package semana4.matrices.ejercicios;

import java.util.Random;

public class Matrices05 {

	public static void main(String[] args) {

		int[][] m1 = new int[5][5];
		int mayor = 0;
		for (int i = 0; i < m1.length; i++) {
			for (int j = 0; j < m1[0].length; j++) {
				m1[i][j] = new Random().nextInt(50) + 1;
			}
		}

		// mostrar matriz 5x5
		for (int i = 0; i < m1.length; i++) {
			for (int j = 0; j < m1[0].length; j++) {
				System.out.print(m1[i][j] + "\t");
			}
			System.out.println();
		}
		// calcular el mayor
		for (int i = 0; i < m1.length; i++) {
			for (int j = 0; j < m1[0].length; j++) {
				if (m1[i][j] > mayor) {
					mayor = m1[i][j];
				}
			}
		}
		// mostrar posicion del mayor
		for (int i = 0; i < m1.length; i++) {
			for (int j = 0; j < m1[0].length; j++) {
				if (m1[i][j] == mayor) {
					System.out.println("El mayor es el numero " + mayor
							+ " y esta en la posicion: [" + i + "]" + "[" + j
							+ "]");
				}
			}
		}

	}

}
